<?php
!defined("EW_ROOT") && exit('No direct script access allowed');
/**
* Ecommerce Web Content Management System
* @copyright (c) 2011 ewcms team http://www.ewcms.org
* @license  GNU GENERAL PUBLIC LICENSE (GPLv3)
* @author iceweb
*/
class wsModel
{
	protected static $DB=NULL;
	protected static $dbConfig=array();
	
	public static function getInstance()
	{
		self::$dbConfig=setting::getDb();
		if(is_null(self::$DB))
		{
			/**
			 * 载入SQL工具类
			 */
			require_once EW_ROOT.'source/util/sqlTool.class.php';
			/**
			 * 载入数据库接口类
			 */
			require_once EW_ROOT.'source/database/dbInterface.php';
			/**
			 * 载入数据库驱动类
			 */
			require_once EW_ROOT.'source/database/'.self::$dbConfig['dbType'].'.class.php';
			new wsModel();
		}
		return self::$DB;
	}
	/**
	 * 获取数据库对象
	 */
	public static function dbPrefix()
	{
		return self::$dbConfig['dbPrefix'];
	}
	
	private function __construct()
	{
		self::$DB=new self::$dbConfig['dbType'];
	}
}